package com.ymatou.iapi.thirdpartysync.service;

import java.util.List;

import com.google.common.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.shop2cn.iapi.agentproducts.parameter.ProductListDto;
import com.ymatou.iapi.thirdpartysync.parameter.PromotionDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;
/**
*查询推广商品列表Call
*FreeMaker Template自动生成代码
*/
public class QueryPromotionProductsCall extends YmatouBaseCall{
	private static String opurl ="promote/queryPromotionProducts";
	
	public QueryPromotionProductsCall() {
		super(EnvSetup.getSystemUrl("thirdpartysync_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	public List<PromotionDto> getPromotionDtos(){
		String sResults = getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList").toString();
		List<PromotionDto> FreezeProductResultList=(List<PromotionDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<PromotionDto>>(){}.getType());
		return FreezeProductResultList;
	}
}